﻿<Window xmlns:my1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"  
        x:Class="EnergyGeneratorSimVisualizer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:EnergyGeneratorSimVisualizer.ViewModels"
        xmlns:view="clr-namespace:EnergyGeneratorSimVisualizer.Views"
        xmlns:EnergyGeneratorSimVisualizer="clr-namespace:EnergyGeneratorSimVisualizer.Views"
        xmlns:my="clr-namespace:EnergyGeneratorSimVisualizer.Converter"
        xmlns:res="clr-namespace:EnergyGeneratorSimVisualizer"
        Title="{x:Static res:Translations.WindowTitle}"
        Height="300"
        Width="1000"
        WindowState="Maximized"
        WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <DataTemplate DataType="vm:SimulationParametersViewModel">
            <view:SimulationParametersView />
        </DataTemplate>
        <my:BooleanToVisibilityConverter x:Key="boolVis" />

        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Margin"
                    Value="5,2" />
            <Setter Property="VerticalAlignment"
                    Value="Center" />
            <Setter Property="MaxWidth"
                    Value="150" />
            <Setter Property="TextWrapping"
                    Value="Wrap" />
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Margin"
                    Value="5,1" />
            <Setter Property="TextAlignment"
                    Value="Right" />
            <Setter Property="MinWidth"
                    Value="30" />
            <Setter Property="VerticalAlignment"
                    Value="Center" />
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="1">
            <ToolBarTray DockPanel.Dock="Top">
                <ToolBar>
                    <TextBlock>Settings:</TextBlock>
                    <Button Click="LoadSettingsClick">Load</Button>
                    <Button Click="SaveSettingsClick">Save</Button>
                </ToolBar>
            </ToolBarTray>

            <my1:Accordion VerticalAlignment="Stretch"
                       HorizontalAlignment="Stretch"
                       VerticalContentAlignment="Stretch"
                       HorizontalContentAlignment="Stretch"
                        DataContext="{Binding SimulationParameters}">
                <my1:AccordionItem Header="Simulation">
                    <EnergyGeneratorSimVisualizer:SimulationParameterView HorizontalAlignment="Stretch" 
                                                                          VerticalAlignment="Stretch" />
                </my1:AccordionItem>
                <my1:AccordionItem Header="Spulenparameter">
                    <EnergyGeneratorSimVisualizer:CoilParameterView DataContext="{Binding Inductor}" />
                </my1:AccordionItem>
                <my1:AccordionItem Header="Permanentmagnet">
                    <EnergyGeneratorSimVisualizer:PermanentMagnetView DataContext="{Binding PermanentMagnet}" />
                </my1:AccordionItem>
                <my1:AccordionItem Header="Allgemein">
                    <EnergyGeneratorSimVisualizer:GeneralParameterView DataContext="{Binding General}" />
                </my1:AccordionItem>
                <my1:AccordionItem Header="Charts">
                    <EnergyGeneratorSimVisualizer:ChartConfiguration x:Name="chartConfiguration" 
                                                                     CheckedChangedHandler="OnChartChanged"/>
                </my1:AccordionItem>
            </my1:Accordion>
        </DockPanel>
        <GridSplitter Grid.Column="1"
                      Grid.Row="1"
                      ResizeBehavior="PreviousAndNext" 
                      Width="5"/>
        
        <Grid Grid.ColumnSpan="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <TextBlock Text="Simulation"
                       FontWeight="Bold"
                       FontSize="16" />
            <Button Grid.Row="1"
                    Content="Simulation starten"
                    Click="StartSimulationClick"
                    Visibility="{Binding Path=IsNotCalculating, Converter={StaticResource boolVis}}"/>
            <Button Grid.Row="1"
                    Content="Abbruch"
                    Click="CancelSimulationClick"
                    Visibility="{Binding Converter={StaticResource boolVis}, Path=IsCalculating}" />
            <ProgressBar Grid.Row="1"
                         Grid.Column="1"
                         Minimum="0"
                         Maximum="{Binding ProgressReportMaximum}"
                         Value="{Binding ProgressReportCurrentValue}" />
        </Grid>

        <TabControl Grid.Row="1"
                    Grid.Column="2">
            <TabItem Header="Parameters">
                <view:SimulationParametersView DataContext="{Binding SimulationParameters}" />
                <!--ContentPresenter Content="{Binding SimulationParameters}" /-->
            </TabItem>
            <TabItem Header="Simulation">
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <ListBox ItemsSource="{Binding LoggingOutput}"
                             Name="loggingDisplay"/>

                    <GridSplitter Grid.Column="1"
                                  ResizeBehavior="PreviousAndNext"
                                  Width="5" />

                    <view:ChartDisplayArea x:Name="chartDisplayArea" Grid.Column="2" />
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
